package com.gzy.xuexiziliao.service.impl;

import com.gzy.xuexiziliao.mapper.HealthRecordsMapper;
import com.gzy.xuexiziliao.pojo.entity.HealthRecords;
import com.gzy.xuexiziliao.service.HealthRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

@Service
public class HealthRecordsServiceImpl  implements HealthRecordsService {
    @Autowired
    private HealthRecordsMapper healthRecordsMapper;

    /**
     * 添加健康记录
     * @param hr
     */
    @Override
    public void save(HealthRecords hr) {
        hr.setUpdateTime(LocalDate.now());
        healthRecordsMapper.save(hr);
    }

    /**
     * 根据id查询健康记录
     * @param id
     * @return
     */
    @Override
    public HealthRecords getById(Integer id) {
        HealthRecords healthRecords = healthRecordsMapper.getById(id);
        return healthRecords;
    }

    /**
     * 修改健康记录
     * @param hr
     */
    @Override
    public void update(HealthRecords hr) {
        hr.setUpdateTime(LocalDate.now());
        healthRecordsMapper.update(hr);
    }
}
